<?php

/**
 * 默认控制器
 */
class Controller_Interface extends Controller_Abstract
{
	function actionapply()
	{
		if(isset($_SESSION['dk_last']))
		{
			$lasttime = $_SESSION['dk_last'];
			//dump($vars);
			if ( (time() - $lasttime)< 300 )
					{
						exit('1小时内只能申请1次');
					}
		}
		#用途
		$request = $this->_context;
		$yt = $request['yongtu'];
		$expday = $request['expday'];
		$balance = $request['balance'];
		
		$diya = $request['diya'];
		$area = $request['area'];
		$desc = $request['desc'];
		$name = $request['name'];
		
		$mobile = $request['mobile'];
		$sex = $request['sex'];
		if (!$yt)
		{
			exit('贷款类型必须填写');
		}
		if (!$balance)
		{
			exit('金额必须填写');
		}
		if (!$name)
		{
			exit('您的名字不能为空');
		}
		if (!$mobile)
		{
			exit('联系号码必须填写');
		}
		$new = array(
				'yongtu'=>strip_tags($yt),
				'expday'=>strip_tags($expday),
				'balance'=>floatval($balance),
				'diya'=>strip_tags($diya),
				'area'=>strip_tags($area),
				'desc'=>strip_tags($desc),
				'name'=>strip_tags($name),
				'mobile'=>strip_tags($mobile),
				'sex'=>strip_tags($sex)
				);
		$obj = new Daikuan($new);
		try {
			$obj->save(0,'create');
			$_SESSION['dk_last'] = time();
			echo '1';
		} catch (Exception $e) {
			dump($e->getmessage());
			echo '0';
		}
		exit();
	}
   
    function actionCode()
    {
    	return Helper_Ckcode::entry();
    }
    function actionloadloana()
    {
    	$type = ($this->_context->type);
    	$data = q::ini('appini/product/yt');
    	
    	$result = '';
    	foreach ($data[$type] as $k=>$v)
    	{
    		$result.= '<option value="'.$v.'">'.$v.'</option>';
    	}
    	exit($result);
    }
}